import { fileURLToPath, URL } from "node:url"

import { defineConfig } from "vite"
import vue from "@vitejs/plugin-vue"
import vueDevTools from "vite-plugin-vue-devtools"
import Components from "unplugin-vue-components/vite"
import { AntDesignVueResolver } from "unplugin-vue-components/resolvers"

// https://vite.dev/config/
export default defineConfig({
    base: "/bigScreen",
    plugins: [
        vue(),
        vueDevTools(),
        Components({
            resolvers: [
                AntDesignVueResolver({
                    importStyle: false, // css in js
                }),
            ],
        }),
    ],
    resolve: {
        alias: {
            "@": fileURLToPath(new URL("./src", import.meta.url)),
        },
    },
    server: {
        port: 8080, // 开发服务器端口
        open: true, // 自动打开浏览器
        proxy: {
            "/api": {
                target: "http://localhost:8888/bigScreen",
                changeOrigin: true,
                secure: false, // 禁用证书验证
                rewrite: (path) => path.replace(/^\/api/, ""),
            },
        },
    },
})
